/**
 * @file
 */
 
#ifndef WII_GI_C_SPRITE_H
#define WII_GI_C_SPRITE_H

#include "c_Texture.h"

namespace wiigi
{
   /**
    * A simple sptite class
    */
   class c_Sprite
   {
      public:
         c_Sprite();
         ~c_Sprite();
         
         e_Status init( 
            c_Texture* Texture
         );
         
         e_Status init( 
            c_Texture* Texture, 
            c_u32Rect& FrameSize
         );
         
         e_Status init( 
            c_Texture* Texture, 
            c_u32Rect& FrameSize,
            u32              FrameCnt
         );
         
         e_Status draw( void );
         
         void setRotation( f32 Rotation )
         {
            m_Rotation = Rotation;
            
            return;
         }
         
         bool isVisible( const c_f32Rect& ScreenArea ) const;
         
         void setPosition( const c_f32Vector2d& Position )
         {
            m_Position = Position;
            
            return;
         }
         
         void setPosition( f32 Xpos, f32 Ypos )
         {
            m_Position.setValues( Xpos, Ypos );
            
            return;
         }
            
         c_Texture* getTexture( void ) const
         {
            return m_Texture;
         }   
         
         void setCurrentFame( u32 Frame )
         {
            m_CurrentFrame = Frame;
            
            return;
         }
         
         u32 getCurrentFrame( void ) const
         {
            return m_CurrentFrame;
         }
         
         void setAlpha( u8 Alpha )
         {
            m_Colour &= 0xFFFFFF00;
            m_Colour |= Alpha;
            
            return;
         }
         
         u32 getFrameCnt( void ) const
         {
            return m_FrameCnt;
         }
         
         /**
          * called by game engine before start drawing any of the sprites.
          */               
         static void setupDrawing( void )
         {
            m_CurrentTexture = (c_Texture*)0;
            
            return;
         }
            
      protected:
         c_Texture*       m_Texture;                      /**< Texture for this sprite instance */
         f32              m_Rotation;
         c_f32Vector2d    m_Position;
         c_f32Vector2d    m_Scale;
         u32              m_Colour;    
         u32              m_CurrentFrame;
         
         u32                         m_FrameCnt;
         c_u32Rect                   m_FrameSize;       /**< Frame size being used by this sprite */
         c_Texture::s_2D_TextCoords* m_Frames;          /**< Array of texture coords that represent each frame within our source texture */
            
            
         static c_Texture*  m_CurrentTexture;            /**< Last texture used when drawing a sprite */
            
   };
   
}

#endif //WII_GI_C_SPRITE_H
